package com.example.java_dao;

import com.example.java_pojo.Brand;
import org.apache.ibatis.annotations.*;

import java.sql.Array;
import java.util.ArrayList;
import java.util.List;

@Mapper
public interface BrandDao {
    @Select("select * from tb_brand")
//    @ResultMap("brand")
    List<Brand> selectAll();

    @Insert("insert into tb_brand values(null,#{brand_name},#{company_name},#{ordered},#{description},#{status})")
//    @ResultMap("brand")
    void add(Brand brand);

    @Update("update tb_brand set " +
            "brand_name=#{brand_name}," +
            "company_name=#{company_name}," +
            "ordered=#{ordered}," +
            "description=#{description}," +
            "status=#{status} " +
            "where id=#{id}")
    void update(Brand brand);

    @Delete("delete from tb_brand where id=#{id}")
    void delete(Integer id);

    @Select("select * from tb_brand where company_name like concat('%',#{company_name},'%') and brand_name like concat('%',#{brand_name},'%')")
    List<Brand> selectBrand(String company_name, String brand_name);

    @Delete("<script>delete from tb_brand where id in <foreach collection='array' open='(' item='id' separator=',' close=')' >#{id}</foreach></script>")
    void deleteByIds(Integer[] ids);
}
